const low = require('lowdb')
const FileSync = require('lowdb/adapters/FileSync')

const adapter = new FileSync('db.json')
const db = low(adapter)

// db.defaults({ posts: [], user: {} }).write()

// db.get('posts').unshift({ id: 3, title: '天气不错' }).write()

// console.log(db.get('posts').value())

// const res = db.get('posts').remove({ id: 2 }).write()
// console.log(res)

// let res = db.get('posts').find({ id: 1 }).value()
// console.log(res)

db.get('posts').find({ id: 1 }).assign({ title: '下雨了' }).write()
